function show(i) {
  document.all.txtType[i].checked = true;
	if (i==0) {
	  document.all("divTxt").style.display = "";
	  document.all("divHtml").style.display = "none";
	  txtForm.focus();
	  txtForm.content.focus();
	  txtForm.content.hideFocus = true;
	} else {
	  document.all("divTxt").style.display = "none";
	  document.all("divHtml").style.display = "";
	}
}


function replace(string,text,by) 
{
	if (string.length==0 || text.length==0) return string;
	var i = string.indexOf(text);
	if (((!i) && (text != string.substring(0,text.length))) || (i== -1)) return string;
	var newstr = string.substring(0,i) + by;
	if (i+text.length < string.length) newstr += replace(string.substring(i+ text.length, string.length), text, by);
	return newstr;
}

function c2e(text) 
{
	//text=replace(text,"\r","");
	//text=replace(text,"\n","<BR>\n");
	text=replace(text,"<BR>\n<UL>","\n<UL>");
	text=replace(text,"<UL><BR>","<UL>");
	text=replace(text,"</UL><BR>","</UL>");
	text=replace(text,"<BR>\n<OL>","\n<OL>");
	text=replace(text,"<OL><BR>","<OL>");
	text=replace(text,"</OL><BR>","</OL>");
	text=replace(text,"<BR>\n<LI>","\n<LI>");
	text=replace(text,"#SCRIPT","<SCRIPT");
	text=replace(text,"#/SCRIPT#","</SC"+"RIPT>");
	text=replace(text,"#T","<T");
	text=replace(text,"#/T","</T");	
	HtmlEdit.setHTML(text)
}

function e2c() 
{
	text=HtmlEdit.getHTML();
	//text=replace(text,"<BR>","\n");
	//text=replace(text,"<P>","");
	//text=replace(text,"</P>","<br>");
	text=replace(text,"STRONG>","B>");
	text=replace(text,"EM>","I>");
	//text=replace(text,"/UL>\r\n","/UL>");
	//text=replace(text,"/OL>\r\n","/OL>");
	text=replace(text,"</UL>","\r\n</UL>");
	text=replace(text,"</OL>","\r\n</OL>");
	text=replace(text,"</BLOCKQUOTE>","\r\n</BLOCKQUOTE>");
	text=replace(text,"<SCRIPT","#SCRIPT");
	text=replace(text,"</SC"+"RIPT>","#/SCRIPT#");
	text=replace(text,"<A","<A target='_blank'");
	//多彩留言里粘贴来的表格会把留言簿排版打乱,故将其tag都显化.
	text=replace(text,"<T","#T");
	text=replace(text,"</T","#/T");	
	htmlForm.content.value=text;
}

function setHtml(id,text)
{
	htmlForm.id.value=id;
	document.all.htmlMod.style.display="";
	document.all.txtMod.style.display="none";
	txtForm.reset();
	c2e(text);
	show(1);
}
function setSignHtml(sign)
{
	htmlForm.signno[sign].selected = true;
}

function setTxt(id,text)
{
	txtForm.id.value=id;
	document.all.htmlMod.style.display="none";
	document.all.txtMod.style.display="";
	txtForm.content.value=text;
	htmlForm.reset();
	c2e('');
	show(0);
}

function setSignTxt(sign)
{
	txtForm.signno[sign].selected = true;
}